package com.hcbd.tdwt.base.other;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.view.KeyEvent;
import android.widget.Toast;

public class KeyBroadcastReceiver extends BroadcastReceiver {

    private String TAG = "KeyBroadcastReceiver";

    @Override
    public void onReceive(Context context, Intent intent) {
        Log.e(TAG, "收到广播："+intent.getAction());
        // 处理接收到的按键事件
        if (Intent.ACTION_MEDIA_BUTTON.equals(intent.getAction())) {
            KeyEvent event = intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT);
            if (event != null && event.getAction() == KeyEvent.ACTION_DOWN) {
                int keyCode = event.getKeyCode();
                Log.e(TAG, "按键事件："+keyCode);
                // SOS 按键
                if (keyCode == KeyEvent.KEYCODE_F1) {

                }
            }
        }
    }
}
